/* Copyright 2019 Noah Frederick
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "my.h"
#include "my_leader.h"

enum combo_events {<% combos.select {|c| c.complex? }.each do |combo| %>
  <%= combo.constant_name %>,<% end %>
};
<% combos.each do |combo| %>
const uint16_t PROGMEM <%= combo.array_name %>[] = { <%= combo.keys.join(', ') %>, COMBO_END };<% end %>

combo_t key_combos[COMBO_COUNT] = {<% combos.each do |combo| %>
  <% if combo.complex? %>[<%= combo.constant_name %>] = COMBO_ACTION(<%= combo.array_name %>),<% else %>COMBO(<%= combo.array_name %>, <%= combo.action %>),<% end %><% end %>
};

#define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))
#define SEND_CAP_STRING(str, capitalized) if (MODS_SHIFT) { \
                                            clear_mods(); \
                                            SEND_STRING(capitalized); \
                                          } else { \
                                            SEND_STRING(str); \
                                          }

void process_combo_event(uint8_t combo_index, bool pressed) {
  switch(combo_index) {<% combos.select {|c| c.complex? }.each do |combo| %>
    case <%= combo.constant_name %>:
      if (pressed) {<% combo.action.chomp.split("\n").each do |line| %>
        <%= line %><% end %>
      }
      break;<% end %>
  }
}
